
import { EventTarget } from 'cc';
export enum MyEventType {
     Notice = 'Notice',
     CloseUI = 'CloseUI',
     ModalConfirm = 'ModalConfirm',

     PlaneTouchMove = 'PlaneTouchMove',
     PlaneTouchEnd = 'PlaneTouchEnd',
     PlaneTouchCancel = 'PlaneTouchEnd',
     PlaneClick = 'PlaneClick',
     GetVillageDetail = 'GetVillageDetail',
     SpaceClick = 'SpaceClick',
     WallClick = 'WallClick',
     BGCLICK = 'BgClick',
     BuildingListRefresh = 'BuildingListRefresh',
     DevelopComplete = 'DevelopComplete',
     AdvancedComplete = 'AdvancedComplete',

     RefreshDiamond = 'RefreshDiamond',
     TrainSoldier = 'TrainSoldier',

     SelectVillage = 'SelectVillage',
     TraderTimeDown = 'TraderTimeDown',
     TraderBack = 'TraderBack',
     TargetVillage = 'TargetVillage',
     ArmySetOff = 'ArmySetOff',
     SelectBuilding = 'SelectBuilding',

     FightOperationComplete = 'FightOperationComplete',
     RefreshStone = 'RefreshStone',

     RefreshTreaList = 'RefreshTreaList',

     HeroLocationChange = 'HeroLocationChange',
     RefreshOasisList = 'RefreshOasisList',

     romList = 'romList',

     ShopList = 'ShopList',

     RefreshInviteMeList = 'RefreshInviteMeList',

     RefreshMeApplyList = 'RefreshMeApplyList',
     RefreshOtherApplyList = 'RefreshOtherApplyList',
     RefreshInviteOtherList = 'RefreshInviteOtherList',
     KickoutAlly = 'KickoutAlly',
     AllyRedDot = 'AllyRedDot',
     BuildWall = 'BuildWall',
     RemoveWall = 'RemoveWall',

     HeroMove = 'HeroMove',
     ReceiveTaskBonus = 'ReceiveTaskBonus',
}

export class EventManager {
     public static _instance: EventManager;
     public static get instance(): EventManager {
          if (this._instance == null) {
               this._instance = new EventManager()
          }

          return this._instance
     }

     public static EventType = MyEventType

     private eventTarget = new EventTarget();

     emit(name: string, data: any) {
          this.eventTarget.emit(name, data)
     }
     on(name, func, target) {
          this.eventTarget.on(name, func, target)
     }

     once(name, func, target) {
          this.eventTarget.once(name, func, target)
     }

     off(name, func, target) {
          this.eventTarget.off(name, func, target)
     }
}


